package cn.tkd.client.gold.context;

import cn.tkd.client.gold.model.AgentDO;

import com.extjs.gxt.ui.client.store.ListStore;

/**
 * @author 嘉陵江里捉鱼 email:tang7259@163.com
 *@version 1.0
 *@time Nov 3, 2008 11:10:30 AM
 */
public class AgentEventContext {

	private static ListStore<AgentDO> list;

	public static ListStore<AgentDO> getStore() {
		load();
		return list;
	}

	public static AgentDO getAgent(int id) {
		load();
		for (int i = 0; i < list.getCount(); i++) {
			AgentDO item = list.getAt(i);
			if (item.getId().equalsIgnoreCase(id + "")) {
				return item;
			}
		}
		return new AgentDO(-1, "不存在快递公司", false);
	}

	public static void load() {
		if (list == null) {
			list = new ListStore<AgentDO>();
			list.add(new AgentDO(1, "圆通", true));
			list.add(new AgentDO(2, "申通", true));
			list.add(new AgentDO(3, "EMS", true));
			list.add(new AgentDO(4, "顺丰", true));
			list.add(new AgentDO(5, "韵达", true));
			list.add(new AgentDO(6, "汇通", true));
			list.add(new AgentDO(7, "天天", true));
			list.add(new AgentDO(8, "亚风", true));
			list.add(new AgentDO(9, "中诚", true));
			list.add(new AgentDO(10, "中通", true));
			list.add(new AgentDO(11, "长发", true));
			list.add(new AgentDO(12, "能达", true));
			list.add(new AgentDO(13, "全一", false));
			list.add(new AgentDO(14, "E邮宝", false));
			list.add(new AgentDO(16, "风火", false));
			// AgentDataProxy proxy = new AgentDataProxy(Request.getAgents());
			// ListLoader loader = new BaseListLoader(proxy, new
			// AgentReader<ModelData>()) {
			//
			// @Override
			// protected void onLoadSuccess(Object loadConfig, Object data) {
			// super.onLoadSuccess(loadConfig, data);
			// Dispatcher.forwardEvent(AppEvents.ALL_AGENT_LOADED);
			//
			// }
			//
			// };
			// store = new ListStore<AgentDO>(loader);
			// loader.load();
		}
	}
}
